let instance

/**
 * 统一的音效管理器
 */
export default class Music {
  constructor() {
    if ( instance )
      return instance

    instance = this

    this.bgmAudio = new Audio()
    this.bgmAudio.loop = true
    this.bgmAudio.src  = 'audio/bgm.mp3'

    this.giftAudio     = new Audio()
    this.giftAudio.src = 'audio/get.mp3'

    this.overAudio     = new Audio()
    this.overAudio.src = 'audio/over.mp3'

    this.playBgm()
  }

  playBgm() {
    this.bgmAudio.play()
  }

  playGift() {
    this.giftAudio.currentTime = 0
    this.giftAudio.play()
  }

  playExplosion() {
    this.overAudio.currentTime = 0
    this.overAudio.play()
  }
}
